package com.ecr.hub.model.wagon;

import com.ecr.hub.model.AbstractIndicatorBaseHub;

/**
 * Pour l'application, toujours dans un but de simplification et dans l'objectif
 * de manipuler le moins d'objets possibles, il n'y a qu'une seule entité,
 * l'entité wagon. Par contre, l'attribut "Trailer" (tracté) permet de savoir
 * s'il s'agit véritablement d'un wagon ou d'une locomotive (wagon non tracté).
 * Comme le coodinateur gère à 95% des wagons et que le positionnement des
 * locomotives est purement informatif, cette option a été choisie afin de
 * simplifier la manipulation des véhicules présents sur le hub. Afin de faire
 * des liaison multi-tables simples, la table "hub_status_wagon" contient en
 * fait les statuts des wagons et des locomotives.
 */
public class Wagon extends AbstractIndicatorBaseHub implements Cloneable {

	private static final long serialVersionUID = 1L;
	private String extId;
	private String owner;
	private String lading;
	private float weightLading;
	private WagonType type;
	private WagonStatus currentStatus;
	private WagonStatus nextStatus;
	private String riv; // TODO mettre en booleen.
	private String fromRail;
	private int numLot;
	private String ate;
	private float brakeForce;
	// La position actuelle du wagon.
	private WagonPosition currentPos;
	// La nouvelle position demandée du wagon.
	private WagonPosition nextPos;
	// La dernière position demandée du wagon.
	private WagonPosition lastPos;
	// Autres.
	private String hexColor;
	private int destinationId;
	private String tcmsTrainId;
	private int sillonId;
	private String sillonExtId;
	private String destinationLabel;
	private String fuelLevel;
	// Utilisé pour la recherche wagon dans le traffic.
	private boolean inquired;

	public Wagon() {
		setCurrentStatus(new WagonStatus());
		setNextStatus(new WagonStatus());
		setCurrentPos(new WagonPosition());
		setNextPos(new WagonPosition());
		setLastPos(new WagonPosition());
		setType(new WagonType());
		setInquired(false);
	}

	// ******************************
	// Les getters et les setters.
	// ******************************

	public String getOwner() {
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	public String getHexColor() {
		return hexColor;
	}

	public void setHexColor(String hexColor) {
		this.hexColor = hexColor;
	}

	public int getDestinationId() {
		return destinationId;
	}

	public void setDestinationId(int destinationId) {
		this.destinationId = destinationId;
	}

	public String getRiv() {
		return riv;
	}

	public void setRiv(String riv) {
		this.riv = riv;
	}

	public WagonType getType() {
		return type;
	}

	public void setType(WagonType type) {
		this.type = type;
	}

	public String getExtId() {
		return extId;
	}

	public void setExtId(String extId) {
		this.extId = extId;
	}

	public String getLading() {
		return lading;
	}

	public void setLading(String lading) {
		this.lading = lading;
	}

	public float getWeightLading() {
		return weightLading;
	}

	public void setWeightLading(float weightLading) {
		this.weightLading = weightLading;
	}

	public WagonPosition getCurrentPos() {
		return currentPos;
	}

	public void setCurrentPos(WagonPosition currentPos) {
		this.currentPos = currentPos;
	}

	public WagonPosition getNextPos() {
		return nextPos;
	}

	public void setNextPos(WagonPosition nextPos) {
		this.nextPos = nextPos;
	}

	public String getFromRail() {
		return fromRail;
	}

	public void setFromRail(String fromRail) {
		this.fromRail = fromRail;
	}

	public String getTcmsTrainId() {
		return tcmsTrainId;
	}

	public void setTcmsTrainId(String tcmsTrainId) {
		this.tcmsTrainId = tcmsTrainId;
	}

	public WagonPosition getLastPos() {
		return lastPos;
	}

	public void setLastPos(WagonPosition lastPos) {
		this.lastPos = lastPos;
	}

	public int getNumLot() {
		return numLot;
	}

	public void setNumLot(int numLot) {
		this.numLot = numLot;
	}

	public boolean isInquired() {
		return inquired;
	}

	public void setInquired(boolean inquired) {
		this.inquired = inquired;
	}

	public WagonStatus getCurrentStatus() {
		return currentStatus;
	}

	public WagonStatus getNextStatus() {
		return nextStatus;
	}

	public void setCurrentStatus(WagonStatus currentStatus) {
		this.currentStatus = currentStatus;
	}

	public void setNextStatus(WagonStatus nextStatus) {
		this.nextStatus = nextStatus;
	}

	public int getSillonId() {
		return sillonId;
	}

	public void setSillonId(int sillonId) {
		this.sillonId = sillonId;
	}

	public String getDestinationLabel() {
		return destinationLabel;
	}

	public void setDestinationLabel(String destinationLabel) {
		this.destinationLabel = destinationLabel;
	}

	public String getFuelLevel() {
		return fuelLevel;
	}

	public void setFuelLevel(String fuelLevel) {
		this.fuelLevel = fuelLevel;
	}

	public String getAte() {
		return ate;
	}

	public void setAte(String ate) {
		this.ate = ate;
	}

	public float getBrakeForce() {
		return brakeForce;
	}

	public void setBrakeForce(float brakeForce) {
		this.brakeForce = brakeForce;
	}

	public String getSillonExtId() {
		return sillonExtId;
	}

	public void setSillonExtId(String sillonExtId) {
		this.sillonExtId = sillonExtId;
	}

	// **********************
	// Le clone du wagon.
	// **********************

	public Object clone() {

		Wagon w = null;
		try {
			w = (Wagon) super.clone();
			w.setCurrentStatus((WagonStatus) currentStatus.clone());
			w.setNextStatus((WagonStatus) nextStatus.clone());
			w.setCurrentPos((WagonPosition) currentPos.clone());
			w.setNextPos((WagonPosition) nextPos.clone());
			w.setLastPos((WagonPosition) lastPos.clone());
			w.setType((WagonType) type.clone());
		} catch (CloneNotSupportedException e) {
			// RAS.
		}
		return w;
	}
}
